home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / FPUTS.C < prev    next >
C/C++ Source or Header  |  1992-03-02  |  1KB  |  48 lines

  1. /* This is file FPUTS.C */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. /*
  8.  * Copyright (c) 1984 Regents of the University of California.
  9.  * All rights reserved.  The Berkeley software License Agreement
  10.  * specifies the terms and conditions for redistribution.
  11.  */
  12.  
  13. #if defined(LIBC_SCCS) && !defined(lint)
  14. static char sccsid[] = "@(#)fputs.c    5.2 (Berkeley) 3/9/86";
  15. #endif LIBC_SCCS and not lint
  16.  
  17. #include    <stdio.h>
  18.  
  19. fputs(s, iop)
  20. register const char *s;
  21. register FILE *iop;
  22. {
  23.     register r = 0;
  24.     register c;
  25.     int unbuffered;
  26.     char localbuf[BUFSIZ];
  27.  
  28.     unbuffered = iop->_flag & _IONBF;
  29.     if (unbuffered) {
  30.         iop->_flag &= ~_IONBF;
  31.         iop->_ptr = iop->_base = localbuf;
  32.         iop->_bufsiz = BUFSIZ;
  33.     }
  34.  
  35.     while (c = *s++)
  36.         r = putc(c, iop);
  37.  
  38.     if (unbuffered) {
  39.         fflush(iop);
  40.         iop->_flag |= _IONBF;
  41.         iop->_base = NULL;
  42.         iop->_bufsiz = NULL;
  43.         iop->_cnt = 0;
  44.     }
  45.  
  46.     return(r);
  47. }
  48.